﻿using GENERIC.MVVM.Interfaces.ViewModels;
using GENERIC.MVVM.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace GENERIC.ViewModels
{
    public abstract class ViewModel : GalaSoft.MvvmLight.ViewModelBase, IViewModel
    {
        #region Members

        private bool m_IsBusy;

        #endregion

        #region Properties

        /// <summary>
        /// Obtient ou définit si le view model est occupé
        /// </summary>
        public bool IsBusy
        {
            get { return m_IsBusy; }
            protected set
            {
                if (m_IsBusy != value)
                {
                    m_IsBusy = value;
                    RaisePropertyChanged<bool>(() => IsBusy);
                }
            }
        }

        #endregion

        #region Methodes
        
        public virtual void OnConstructed()
        {
        }

        #endregion
    }

    /// <summary>
    /// Classe de base du AbstractViewModelBase
    /// </summary>
    public abstract class ViewModel<TEntity> : ViewModel
    {
        
        #region Constructor

        /// <summary>
        /// Initalise une nouvelle instance
        /// </summary>
        /// <param name="model">Type de l'entité</param>
        public ViewModel(TEntity model)
        {
            Model = model;
        }

        #endregion

        #region properties

        private TEntity Model { get; set; }

        #endregion
    }
}
